package router

import (
	"gin-gorm-oj/service/adminService"
	"gin-gorm-oj/service/userService"
	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.Default()
	admin := r.Group("/admin")
	//员工相关接口
	employee := admin.Group("/employee")
	{
		employee.POST("/login", adminService.Login)
		employee.POST("", adminService.Register)
		employee.POST("/status/:status", adminService.UpdateEmployeeStatus)
		employee.GET("/:id", adminService.GetEmployeeById)
		employee.PUT("", adminService.UpdateEmployee)
		employee.GET("/page", adminService.EmployeePageList)
	}
	category := admin.Group("/category")
	{
		category.POST("", adminService.SaveCategory)
		category.GET("/page", adminService.CategoryPageList)
		category.PUT("", adminService.UpdateCategory)
		category.POST("/status/:status", adminService.UpdateCategoryStatus)
		category.GET("/list", adminService.GetListByType)
		category.DELETE("", adminService.DelCategory)
	}
	dish := admin.Group("/dish")
	{
		dish.POST("", adminService.AddDish)
		dish.GET("/page", adminService.DishPageList)
		dish.DELETE("", adminService.DeleteDish)
		dish.GET("/:id", adminService.GetDishById)
		dish.GET("/list", adminService.GetDishByCategoryId)
		dish.PUT("", adminService.UpdateDish)
		dish.POST("/status/:status", adminService.UpdateDishStatus)
	}
	//common := admin.Group("/common")
	//{
	//	common.POST("/upload", adminService.FileUpload)
	//}
	setmeal := admin.Group("/setmeal")
	{
		setmeal.POST("", adminService.SaveSetmeal)
		setmeal.GET("/page", adminService.SetmealPageList)
		setmeal.DELETE("", adminService.DeleteSetmealByIds)
		setmeal.PUT("", adminService.UpdateById)
	}
	shop := admin.Group("/shop")
	{
		shop.GET("/status", adminService.GetShopStatus)
		shop.POST("/status/:status", adminService.SetShopStatus)

	}

	user := r.Group("/user")
	category4User := user.Group("/category")
	{
		category4User.GET("/list", userService.GetCategoryList)
	}
	dish4User := user.Group("/dish")
	{
		dish4User.GET("/list", userService.GetDishListByCategoryId)
	}
	setmeal4User := user.Group("/setmeal")
	{
		setmeal4User.GET("/list", userService.GetSetmealById)
	}

	return r
}
